class Solution(object):
    def longestCommonPrefix(self, strs):
        """
        :type strs: List[str]
        :rtype: str
        """
        if len(strs)==0: return ''
        elif len(strs)==1: return strs[0]
        i = 0
        over = False
        while not over:
            c = None
            for s in strs:
                if i==len(s):
                    over = True
                    break
                if c==None: c=s[i]
                if c!=s[i]:
                    over = True
                    break
            if not over:
                i+=1
        return strs[0][0:0+i]


print(Solution().longestCommonPrefix(['a', 'b']))
